#15x15 grid
my @arr =
(
#1 2 3 4 5 6 7 8 9 0 1 2 3 4 5
[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],#1
[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],#2
[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],#3
[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],#4
[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],#5
[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],#6
[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],#7
[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],#8
[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],#9
[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],#10
[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],#11
[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],#12
[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],#13
[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],#14
[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],#15
);
$output = "[";
%isMade;
for $i ( 0 .. $#arr ) {
        $aref = $arr[$i];
        for $j ( 0 .. $#{$aref} ) {
		$output .= "(";
		if(!$isMade{"cell".$i."0".$j}){
			$isMade{"cell".$i."0".$j} = 1;
			if($arr[$i][$j]){
				$output .= "CONWAYALIVE:";
			}
			else{
				$output .= "CONWAYDEAD:";
			}
		}
		else{
			#nothing
		}
		$output .= ("cell".$i."0".$j);
		$output .= ").out->(";
		for($k=-1; $k<2; $k++){
			for($m=-1; $m<2; $m++){
				if(
					(($i + $k) < 0) ||
					(($j + $m) < 0) ||
					(($i + $k) > 14) ||
					(($j + $m) > 14) ||
					(($k == 0) && ($m == 0))
			       ){}
				else{
					$output .= ".in(";
					if(!$isMade{"cell".($i + $k)."0".($j + $m)}){
						$isMade{"cell".($i + $k)."0".($j + $m)} = 1;
						if($arr[$i + $k][$j + $m]){
							$output .= "CONWAYALIVE:";
						}
						else{
							$output .= "CONWAYDEAD:";
						}
					}
					else{
						#nothing
					}
					$output .= ("cell".($i + $k)."0".($j + $m));
					$output .= "), ";
				}
			}
		}
		$output = substr($output, 0, -2);
		$output .= ");\n";			
        }
    }

$output .= "INT:\"1\"->(";
for $i ( 0 .. $#arr ) {
        $aref = $arr[$i];
        for $j ( 0 .. $#{$aref} ) {
		$output .= ".clk(";
		$output .= ("cell".$i."0".$j);
		$output .= "), ";
	}
}
$output = substr($output, 0, -2);
$output .= ");\n";		

for $i ( 0 .. $#arr ) {
        $aref = $arr[$i];
        for $j ( 0 .. $#{$aref} ) {
		if(($i==0)&&($j==0)){
			$output .= "(";
			$output .= ("cell".$i."0".$j);
			$output .= ").out->GUI:\"$i,$j\";\n"; 				
		}
		else{
			$output .= "(";
			$output .= ("cell".$i."0".$j);
			$output .= ").out->GUI:\"$i,$j\";\n"; 		
		}
	}
}
$output .= "]:MAIN;";
open(FILE, ">out.dat");
print FILE $output;